<template>
  <el-container style="height: auto; border: 1px solid #eee">
    <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
      <el-menu :default-openeds="['1']">
        <el-submenu :index="(index + 1) + ''" :key="index" v-for="(menu,index) in menus">
          <template slot="title"><i class="el-icon-message"></i>{{menu.title}}</template>
          <el-menu-item-group>
            <el-menu-item @click="menuItemClick(sub)" :index="(index + 1) + '-' + (subIndex + 1)"
                          v-for="(sub,subIndex) in menu.children" :key="index + '_' + subIndex">{{sub.title}}
            </el-menu-item>
          </el-menu-item-group>
        </el-submenu>
      </el-menu>
    </el-aside>

    <el-container>
      <el-header style="text-align: right; font-size: 12px">
        <el-dropdown>
          <i class="el-icon-setting" style="margin-right: 15px"></i>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>查看</el-dropdown-item>
            <el-dropdown-item>新增</el-dropdown-item>
            <el-dropdown-item>删除</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
        <span>王小虎</span>
      </el-header>
      <el-main>
        <router-view/>
      </el-main>
      <el-footer>
        <p style="text-align: center;">@2019</p>
      </el-footer>
    </el-container>

  </el-container>
</template>

<style>
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }

  .el-aside {
    color: #333;
  }
</style>

<script>
  export default {
    metaInfo: {
      title: '首页',
      titleTemplate: '%s - 我的首页!',
      htmlAttrs: {
        lang: 'zh',
        amp: true
      }
    },
    data() {
      const menuItems = [
        {
          title: 'Map操作', children: [
            { title: '创建地图', url: '/map/create' },
            { title: '异步加载地图', url: '/map/async' },
            { title: '测试', url: '/demo/vuex' }
          ]
        },
        { title: 'City地理定位', children: [] },
        { title: 'DrivingService路线', children: [] },
        { title: 'Geocoder地址解析', children: [] },
        { title: 'SearchService检索服务', children: [] },
        { title: 'MapType地图类型', children: [] },
        { title: 'Marker覆盖物', children: [] },
        { title: 'Event事件', children: [] },
        { title: 'TileLayer图层', children: [] },
        { title: '多边形覆盖物', children: [] },
        { title: 'Control控件', children: [] },
        { title: 'Libraries库', children: [] },
        { title: 'TransferService公交换乘', children: [] },
        { title: '信息窗覆盖物', children: [] },
        { title: 'Vuex', children: [
            { title: 'demo', url: '/demo/vuex' }
          ] }
      ];
      return {
        menus: menuItems
      }
    },
    methods:{
      menuItemClick(menu){
        this.$router.push(menu.url);
      }
    }
  };
</script>

